from django.utils.deprecation import MiddlewareMixin
from django.shortcuts import redirect


class AuthMiddleware(MiddlewareMixin):
    def process_request(self, request):
        if request.path_info in ['/login/', '/img/code/']:
            return
        auth_info = request.session.get('info')
        # print(auth_info)
        if auth_info:
            return
        return redirect('/login/')
